<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Users extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('users', ['comment' => '微信小程序用户表']);
        $table->addColumn('openId', 'string', ['limit' => 40, 'default' => '', 'comment' => '微信用户唯一表示openid'])
            ->addColumn('nickName', 'string', ['limit' => 255, 'default' => '', 'comment' => '微信昵称'])
            ->addColumn('gender', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '性别'])
            ->addColumn('language', 'string', ['limit' => 20, 'default' => '', 'comment' => '用户语言'])
            ->addColumn('city', 'string', ['limit' => 50, 'default' => '', 'comment' => '城市'])
            ->addColumn('province', 'string', ['limit' => 50, 'default' => '', 'comment' => '省份'])
            ->addColumn('country', 'string', ['limit' => 50, 'default' => '', 'comment' => '国家'])
            ->addColumn('avatarUrl', 'string', ['limit' => 255, 'default' => '', 'comment' => '头像'])
            ->addTimestamps()
            ->addSoftDelete();
    }
}
